#pragma once
#include "FMConnection.h"
#include "FMDBParameter.h"
#include "FMDBRecordSet.h"
#include <oratypes.h>
#include "FMDBParameter.h"
#include "FMOCIConstDefine.h"

class FMDBCommand
{
public:
	FMDBCommand(void);
	FMDBCommand(FMDBConnection *connection);
	~FMDBCommand(void);

	void ExecuteSQLNoQuery(CString strSQL,FMDBParameters *Params=NULL,ub4 ExecuteMode=EXECUTION_MODE_DEFAULT);
	void ExecuteSQLNoQueryRepeatly(CString strSQL,int RepeatTimes=1,ub4 ExecuteMode=EXECUTION_MODE_COMMIT_ON_SUCCESS);
	void ExecuteSQL(FMDBRecordSet *rs,CString strSQL,FMDBParameters *Params=NULL,ub4 ExecuteMode=EXECUTION_MODE_DEFAULT);
	void SetParameters(FMDBParameters *Params,int CacheSize=1){m_Params=Params;m_ValueArraySize=CacheSize;}//set data binding parameters
	void SetCacheSize(int CacheSize){m_ValueArraySize=CacheSize;}
	int GetCacheSize(){return m_ValueArraySize;}
	void Close();

public://properties

	//connection
	FMDBConnection *GetConnection(){return m_conn;}
	void SetConnection(FMDBConnection *val)
	{
		if (val)
		{
			m_conn=val;
			m_pOCIErr=m_conn->GetOCIErrorHandle();
		}
	}


	//SQL statement
	CString GetSQLStatement(){return m_strSQL;}
	void SetSQLStatement(CString strSQLStatement){m_strSQL=strSQLStatement;}


private:
	FMDBConnection *m_conn;
	OCIError *m_pOCIErr;//oci error handler

	//note:keep SQL statement so that the statement pool can get best performance
	CString m_strSQL;//SQL statement
	ub4 m_ValueArraySize;

	FMDBParameters *m_Params;

};

